package de.tabuma.pm.gadget.controller;

import de.tabuma.lib.tabumacontroller;
import de.tabuma.pm.*;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author alefen
 */
public class controller extends tabumacontroller {
    public controller(String servlet, Hashtable hashtable) {
        super(servlet, hashtable);
    }
    
    @Override
    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        String id = request.getParameter(constants.gadgetActionId);

        if(id==null) {
            id = "0";
        }
        
        int idInt = Integer.valueOf(id).intValue();
        if(request.getParameter(constants.cancel)!=null) {
            idInt = 0;
        }
        switch(idInt) {
            case constants.GADGET_ACTION_CREATE:
                create create = new create(this.getServlet(), this.getParameter());
                create.navigate(context, request, response, out);
                break;
            case constants.GADGET_ACTION_SETTING:
                settings setting = new settings(this.getServlet(), this.getParameter());
                setting.navigate(context, request, response, out);
                break;
            case constants.GADGET_ACTION_UPDATE:
                update update = new update(this.getServlet(), this.getParameter());
                update.navigate(context, request, response, out);
                break;
            default:
                list list = new list(this.getServlet(), this.getParameter());
                list.navigate(context, request, response, out);
        }
        
    }
}